package com.xuetang9.fujian.threaddemo.bossdemo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author: fujian
 * @description:
 * @date: 2021/5/3 9:29
 * @version: V1.0
 * @package: com.xuetang9.fujian.threaddemo.bossdemo
 **/
@SuppressWarnings("all")
public class BossTest {
    public static void main(String[] args) {
        Boss boss = new Boss("寒冰巨人", 1000);
        System.out.println("当前boss："+ boss.getName() + "血量：" + boss.getHp());
        List<Hero> heroList = new ArrayList<>();
        String[] heroNames = {"1","2","3","4","5"};
        for (int i = 0; i < heroNames.length; i++) {
            // 5个英雄攻击同一个boss
            Hero hero = new Hero(heroNames[i], boss);
            heroList.add(hero);
            new Thread(hero).start();
        }
        try {
            TimeUnit.MILLISECONDS.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        int totalAttack = 0;
        for (Hero hero : heroList) {
            totalAttack += hero.getTotalAttack();
        }
        System.out.println("boss的总学量：" + boss.getHp());
        System.out.println("五名英雄的总伤害：" + totalAttack);
    }
}
